package server;

import config.ApplicationConfig;
import dao.SQL;

import java.util.LinkedHashMap;

/**
 * UserRank: tum0r
 * Package Name: server
 * Time: 2019-01-21 Monday 15:54:47
 */

public class BaseServer {
    SQL sql;
    LinkedHashMap<String, String> config;

    public BaseServer() {
        config = ApplicationConfig.readConfig("database.json");
        sql = new SQL();
    }

    public boolean open() {
        if (sql != null && config != null) {
            return sql.open(config.get("host"), config.get("port"), config.get("database-name"), config.
                    get("username"), config.get("password"));
        }
        return false;
    }

    public boolean close() {
        if (sql != null) {
            return sql.close();
        }
        return false;
    }

}